package edu.cuit.campus.web.converter;

import com.fasterxml.jackson.core.JacksonException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import edu.cuit.campus.enums.Job;

import java.io.IOException;

/**
 * @author <a href="mailto:1020zhaodan@163.com">Adan</a>
 * @version 1.0
 * @date 2025/8/19 15:13
 */
public class JobDeserializer extends JsonDeserializer<Job> {
    @Override
    public Job deserialize(JsonParser parser, DeserializationContext context) throws IOException, JacksonException {
        var source = parser.getText();
        return switch (source){
            case "业务员" -> Job.CLERK;
            case "分析员" -> Job.ANALYST;
            case "销售员" -> Job.SALESMAN;
            case "AI" -> Job.SEARCHER;
            case "经理" -> Job.MANAGER;
            default -> null;
        };
    }
}
